package com.hjc.springbootstudyweb.mapper;

import com.hjc.springbootstudyweb.entity.UsersModel;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: HJC
 * Date: 2019/11/29
 * Time: 11:06
 * To change this template use File | Settings | File Templates.
 */
public interface UsersMapper {

    @Select("SELECT * FROM users")
    @Results({
            @Result(property = "utid" , column = "utid"),
            @Result(property = "uid" , column = "uid"),
            @Result(property = "name" ,column = "name"),
            @Result(property = "address" , column = "address")
    })
    List<UsersModel> queryAll();

    @Select("select * from users where uid =#{uid} and password =#{password} ")
    UsersModel queryById(@Param("uid")String uid,@Param("password")String password);

    @Insert("insert users(uid,password,tel,name,address,addrName) values(#{uid},#{password},#{tel},#{name},#{address},#{addrName})")
    @Options( useGeneratedKeys = true , keyProperty = "utid" , keyColumn = "utid")
    int addUsers(UsersModel usersModel);

    @Delete("delete from users where utid = #{utid}")
    int deleteUsers(@Param("utid")int utid);

}
